{% if page %}
<div id="content-main" class="content-main"
  data-path="{{ path }}"
  data-current-user="{% if user %}{{ user._id.toString() }}{% endif %}"
  data-page-id="{% if page %}{{ page._id.toString() }}{% endif %}"
  data-page-revision-id="{% if revision %}{{ revision._id.toString() }}{% endif %}"
  data-page-revision-created="{% if revision %}{{ revision.createdAt|datetz('U') }}{% endif %}"
  data-page-revision-id-hackmd-synced="{% if revisionHackmdSynced %}{{ revisionHackmdSynced.toString() }}{% endif %}"
  data-page-id-on-hackmd="{% if pageIdOnHackmd %}{{ pageIdOnHackmd.toString() }}{% endif %}"
  data-page-has-draft-on-hackmd="{% if hasDraftOnHackmd %}{{ hasDraftOnHackmd.toString() }}{% endif %}"
  data-page-is-seen="{% if page and page.isSeenUser(user) %}1{% else %}0{% endif %}"
  data-slack-channels="{{ slack|default('') }}"
  >
{% else %}
<div id="content-main" class="content-main"
  data-path="{{ path }}"
  data-current-user="{% if user %}{{ user._id.toString() }}{% endif %}"
  data-slack-channels="{{ slack|default('') }}"
  >
{% endif %}

  {% include 'page_alerts.html' %}

  {% if !getConfig('crowi', 'customize:layout') || 'kibela' === getConfig('crowi', 'customize:layout') %}
    {% include 'page_tabs_kibela.html' %}
  {% else %}
    {% include 'page_tabs.html' %}
  {% endif %}

  <div class="tab-content">

    {% if page %}
      <script type="text/template" id="raw-text-original">{{ revision.body.toString() | encodeHTML }}</script>

      {# formatted text #}
      <div class="tab-pane active" id="revision-body">
        <div class="revision-toc hidden-print" id="revision-toc">
          <a data-toggle="collapse" data-parent="#revision-toc" href="#revision-toc-content" class="revision-toc-head">{{ t('Table of Contents') }}</a>
          <div id="revision-toc-content" class="revision-toc-content collapse in"></div>
        </div>
        <div id="page" class="m-t-15"></div>
      </div>
    {% elseif 'crowi' === getConfig('crowi', 'customize:behavior') %}
      <div class="tab-pane active" id="cancel-creating-portal">
      </div>
    {% endif %}

    {% if not page.isDeleted() %}
      {# edit form #}
      <div class="tab-pane" id="edit">
        <div id="page-editor">{% if pageForm.body %}{{ pageForm.body }}{% endif %}</div>
      </div>
      <div class="tab-pane" id="hackmd">
        <div id="page-editor-with-hackmd"></div>
      </div>
      {% include '../_form.html' %}
    {% endif %}

    {# raw revision history #}
    {% if not page %}
    {% else %}
    <div class="tab-pane revision-history m-t-10" id="revision-history">
    </div>
    {% endif %}

  </div>

  <div id="page-status-alert"></div>
</div>
